import datetime
import time
import queue as Queue
import threading
from time import sleep

from pyalgotrade import bar
from pyalgotrade import barfeed
from pyalgotrade import observer
#from pyalgotrade.bitstamp import common
#from pyalgotrade.bitstamp import wsclient

import Core.Realtimeview as Realtimeview
from livefeed2 import LiveTradeFeed2

class myThread (threading.Thread):
    def run(self):
        while (1):
            print(datetime.datetime.now())
            snapshotList = Realtimeview.ReadList("Snapshot_")
            for key in snapshotList:
                doc = Realtimeview.Read(key)
                print(doc)
            sleep(3)

    def stop(self):
        pass


class RealtimeviewFeed(LiveTradeFeed2):
    def __init__(self, maxLen=None):
        super(RealtimeviewFeed, self).__init__(maxLen)

    def buildClientThread(self):
        return myThread()


#while(1):
#    print(datetime.datetime.now())
#    snapshotList = Realtimeview.ReadList("Snapshot_")
#    for key in snapshotList:
#        doc = Realtimeview.Read(key)
#        print(doc)
#    sleep(3)